package com.demon.framework.boot.autoconfigure.scheduler;

import lombok.extern.slf4j.Slf4j;
import org.quartz.spi.InstanceIdGenerator;

import java.net.InetAddress;
import java.util.UUID;

/**
 * 定时器Id自动生成
 *
 * @author Demon-HY
 * @date 2020/7/24 16:44
 */
@Slf4j
public class QuartzInstanceIdGenerator implements InstanceIdGenerator {

    @Override
    public String generateInstanceId() {
        try {
            return InetAddress.getLocalHost().getHostName() + System.currentTimeMillis();
        } catch (Exception e) {
            log.warn("Couldn't get host name!", e);
            return UUID.randomUUID().toString();
        }
    }
}
